﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Security;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using CARMSBusiness;
using CARMSBusiness.InterFace;
using CARMSData.CollectionClasses;
using CARMSData.EntityClasses;


namespace CARMS
{
    public partial class Main : System.Web.UI.MasterPage
    { 

        protected void Page_Load(object sender, EventArgs e)
        {
            if(!IsPostBack)
            {
                lblLoginName.Text = ((UserData)Session["CurrentLoginUser"]).LoginName;
                LoadDefault();
            }
        }


        private void LoadDefault()
        {
            //var collection = new ButtonEventCollection();
            //collection.GetMulti(null);
            
            //rptEventList.DataSource = collection;
            //rptEventList.DataBind();
        }

        protected void btnLogoutRegister_Click(object sender, EventArgs e)
        {
            var userData = (UserData) Session["CurrentLoginUser"];
            LogBusiness.UpdateLog(Session.SessionID, DateTime.Now, userData.LoginName); 
            FormsAuthentication.SignOut();
            Session.Abandon();
        }

        protected void linkLogOut_Click(object sender, EventArgs e)
        {
            FormsAuthentication.SignOut();
            Session.RemoveAll();
            Response.Redirect("~/login.aspx");
        }
        protected void linkMyProfile_Click(object sender, EventArgs e)
        {
            Response.Redirect("~/Admin/MyProfile.aspx");
        }
        protected void linkChangePassword_Click(object sender, EventArgs e)
        {
            Response.Redirect("~/Admin/ChangePassword.aspx");
        }
        protected void linkHome_Click(object sender, EventArgs e)
        {
            Response.Redirect("~/default.aspx");
        }

        protected void linkMessage_Click(object sender, EventArgs e)
        {
            Response.Redirect("~/Message/MessageList.aspx");
        }
        

        protected void btnChangeLanguage_Click(object sender,EventArgs e)
        {
            if (Session["CurrentCulture"].ToString() == CultureNames.Chinese)
            {
                Session["CurrentCulture"] = CultureNames.ChineseGb;

            }
            else
            {
                Session["CurrentCulture"] = CultureNames.Chinese;
            }
            Response.Redirect(Request.Url.LocalPath);

        }
    }
}
